/*
package com.migu.service;

import SysMenu;
import SysProject;
import SysProjectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

*/
/**
 * @Description TODO :
 * @Author: zj
 * @Date: 15:43 2019/4/17
 * @Version 1.0
 **//*

@Service
@Transactional
public class SysProjectService {
    @Autowired
    private SysProjectRepository projectRepository;

    @Autowired
    private SysMenuService menuService;

    //根据id获取该属菜单的顶级节点id
    public SysProject findProjectById(String id) {
        return projectRepository.findProjectById(id);
    }

    //获取所有应用
    public List<SysProject> findAll() {
        return projectRepository.findAll();
    }

    //添加项目
    public Boolean addProject(SysProject sysProject) {
        if (projectRepository.findIsExists(sysProject) > 0) {
            return false;
        }
        if (projectRepository.addProject(sysProject) == 0) {
            return false;
        }
        //根据添加的应用ProjectParentId查询id
        SysMenu sysMenu = new SysMenu();
        sysMenu.setMenuname(sysProject.getProjectParentNode());
        sysMenu.setParentid(sysProject.getProjectParentId());
        //添加到菜单表
        if (!menuService.savaMenu(sysMenu)) {
            return false;
        }
        return true;
    }

    //删除项目
    public Boolean deleteProjectById(String id) {
        // TODO: 2019/4/18 删除项目
        if (projectRepository.deleteProjectById(id) > 0) {
            return true;
        } else {
            return false;
        }
    }

    //修改项目
    public Boolean updateProject(SysProject sysProject) {
        if (projectRepository.findIsExistsByUpdate(sysProject) > 0) {
            return false;
        }
        if (projectRepository.updateProject(sysProject) == 0) {
            return false;
        }
        return true;
    }
}
*/
